package cloud.take.off.service.sys.impl;

import cloud.take.off.mapper.sys.UserInfoMapper;
import cloud.take.off.module.common.R;
import cloud.take.off.module.order.dto.BaseOrderDTO;
import cloud.take.off.module.order.entity.BaseOrder;
import cloud.take.off.module.order.entity.OrderItem;
import cloud.take.off.module.order.vo.BaseOrderVO;
import cloud.take.off.module.order.vo.OrderItemVO;
import cloud.take.off.module.system.entity.UserInfo;
import cloud.take.off.module.system.query.UserInfoDTO;
import cloud.take.off.module.system.vo.UserInfoVO;
import cloud.take.off.mybatis.base.BaseServiceImpl;
import cloud.take.off.mybatis.support.Condition;
import cloud.take.off.service.sys.UserInfoService;
import cloud.take.off.wrapper.UserInfoWrapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Description: TODO
 * @Author: Take-off
 * @Date: 2024/8/30 3:52 PM
 * @Param
 * @return
 * @Version: 1.0
 **/
@Service
@AllArgsConstructor
public class UserInfoServiceImpl extends BaseServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {

    private final UserInfoWrapper userInfoWrapper;

    @Override
    public boolean submit(UserInfoVO userInfoVO){
        UserInfo userInfo = userInfoWrapper.voToEntity(userInfoVO);
        boolean result = super.saveOrUpdate(userInfo);
        return result;
    }

    @Override
    public UserInfoVO detail(UserInfoDTO dto){
        UserInfoVO userInfoVO = new UserInfoVO();
        UserInfo userInfo = getOne(Condition.getQueryWrapper(userInfoWrapper.dtoToEntity(dto)));
        if (Optional.ofNullable(userInfo).isPresent()){
            userInfoVO = userInfoWrapper.entityToVO(userInfo);
        }
        return userInfoVO;
    }

}
